<?php

namespace App\Modules\Apicrzs\Services\Tools;

use App\Library\SMS\AliyunService;
use App\Modules\Admin\Entities\System\SmsRecordModel;

class SmsService
{

    protected static $smsType = ['aliyun'];
    /**
     * 发送短信
     * @param bool $switch
     * @param $phone
     * @param array $data
     * @param string $mark
     * @return bool
     */
    public static function send( $phone,$code,$type,$time=5)
    {


        $request = AliyunService::send($phone,$code,$type,$time);
        $log_data =[
            'type'=>$type,
            'phone'=>$phone,
            'content' => json_encode($request['content']),
            'code'=>$code,
            'template'=>$request['template'],
            'ip'=>get_ip(),
            'record_id'=>$request['requestId'],
        ];
        $SmsRecordModel = new SmsRecordModel();
        SmsRecordModel::getInstance()->create($log_data);
        return true;
    }

}
